﻿/*----------------------------------------------------------------
 * 
 * 版权所有：Copyright (C) 2012 
 * 
 * 文件名：CEZineController.cs
 * 文件功能描述：
 * 
 * 
 * 作 者：zhangq
 * 邮 箱：zhangqiang@bamabest.com
 * 日 期：2013-03-08 01:36:49
 * 
 * 
 * 修改标识： Author
 * 修改描述： 相关描述
 * 
 * ---------------------------------------------------------------- */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common.Extensions.OrderBy;
using Common.Extensions.Where;
using DomainModel;
using IManager;
using Webdiyer.WebControls.Mvc;

namespace WebPlatform.Areas.CPP.Controllers
{

    /// <summary>
    /// 
    /// </summary>
    public class CEZineController : Controller
    {


        /// <summary>
        /// 
        /// </summary>
        public IManagerDocument IMDocument { get; set; }


        /// <summary>
        /// 
        /// </summary>
        /// <summary>
        /// 
        /// </summary>
        public ActionResult Index(int page = 1, int pageSize = 15)
        {
            
            var p = PredicateExtension.True<DocumentInfo>();
            var count = IMDocument.LoadCount(p);
            var list = IMDocument.LoadAll(p, page, pageSize, 
                new OrderByExpression<DocumentInfo, DateTime>(u => u.UploadDate, true));

            PagedList<DocumentInfo> plist =
                new PagedList<DocumentInfo>(list, page, pageSize, count);

            return View(plist);
        }


        public ActionResult Detail(int aid = 0)
        {
            var doc = IMDocument.GetDocument(aid);
            if (doc == null)
            {
                throw new HttpException(404, string.Format("页面不存在", Request.Path));
            }
            return View(doc);
        }

    }
}
